﻿#region imports

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CondeNet.AssetManager.Data;
using CondeNet.AssetManager.Business;
using CondeNet.AssetManager.Business.Interface;

#endregion

namespace CondeNet.AssetManager.DataProvider.Sql.Mappers
{
    public static class MetaValueMapper
    {
        internal static IMetaValue ToBusinessObject ( T_MetaValue entity )
        {
            IMetaValue obj = new MetaValue (
                entity.MetaValue_IDPK ,
                entity.Value_NVC ,
                entity.LanguageID_FK ,
                entity.Description_NVC ,
                entity.Enabled_BIT.Value );

            if ( entity.T_Language != null ) obj.Language = LanguageMapper.ToBusinessObject ( entity.T_Language );

            return obj;
        }

        internal static T_MetaValue ToEntity ( IMetaValue v )
        {
            T_MetaValue entity = new T_MetaValue ( );

            entity.MetaValue_IDPK = v.ID;
            entity.Value_NVC = v.Value;
            entity.LanguageID_FK = v.LanguageID;
            entity.Description_NVC = v.Description;
            entity.Enabled_BIT = v.Enabled;

            if ( v.Language != null ) entity.T_Language = LanguageMapper.ToEntity ( v.Language );

            return entity;
        }

        internal static IList<IMetaValue> ToBusinessObjects ( IList<T_MetaValue> dalList )
        {
            return dalList.Select ( tmp => ToBusinessObject ( tmp ) ).ToList ( );
        }

        internal static IList<T_MetaValue> ToEntities ( IList<IMetaValue> entityList )
        {
            return entityList.Select ( tmp => ToEntity ( tmp ) ).ToList ( );
        }
    }
}
